package com.servlet; /**
 /**
 * @author zxl
 * @create :2022/9/28
 */


import com.utils.CodeUtils;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/code.jpg")
public class GetCodeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      ServletOutputStream os =response.getOutputStream();
        //生成验证码
        String creatCode= CodeUtils.outputVerifyImage(150,50,os,4);
        //吧验证码存起来
        request.getSession().setAttribute("creatCode",creatCode);

    }

}
